package com.kancy.springcloudconfig.factory;

import com.kancy.springcloudconfig.action.*;
import com.kancy.springcloudconfig.enums.AlgorithmType;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * AlgorithmActionFactory
 * </p>
 *
 * @author: kancy
 * @date: 2019/10/26 14:10
 **/
public class AlgorithmActionFactory {
    private static Map<AlgorithmType, AlgorithmAction> actions = new HashMap(){{
        put(AlgorithmType.Cipher, new CipherAlgorithAction());
        put(AlgorithmType.Jasypt, new JasyptAlgorithAction());
        put(AlgorithmType.Base64, new Base64AlgorithAction());
        put(AlgorithmType.Md5, new Md5AlgorithAction());
        put(AlgorithmType.Rsa, new RsaAlgorithAction());
        put(AlgorithmType.Aes, new AesAlgorithAction());
        put(AlgorithmType.Kms, new KmsAlgorithAction());
    }};

    public static AlgorithmAction getAction(Object algorithmType){
        return actions.get(algorithmType);
    }

}
